
import bpy
from bpy.types import Operator
from 全局控制.Node.节点和插座基类.bl_UpdateNode import *
import 全局控制.Node.节点和插座基类.bl_节点基类 as 基类

类型枚举 = [
	("TYPE_单个", "单个", "", 0),
	("TYPE_区间", "区间", "", 1),
]


class C_SN_元素列表(基类.C_SN_基类):
	bl_dname = 'bl_node_List'
	bl_label = 'List'
	
	#m_帧间隔 = bpy.props.IntProperty(default=1)
	def init(self, context):
		super(C_SceneNode_物体选择, self).__init__()
		self.inputs.new('C_NodeSocket_ni', name='list')
		self.inputs.new('C_NodeSocket_i', name='选取下标')
		self.outputs.new('C_NodeSocket_物体', name='输出List')
		

	def draw_buttons(self, context, layout):
		#layout.prop(self, "m_参考物体")
		#column.prop(self, "m_是否实例")
		#column.prop(self, 'm_物体name前缀')
		pass

	def f_update(self, 是否向下传递=False, input插座=None):
		index = self.inputs['选取下标'].f_getData()
		#取得输入插座连接的输入插座数据
		socket = f_get上一层Output插座(self.inputs['list'])
		data = socket.f_getData(index)
		
		self.outputs['输出List'].f_setData(data)
		


class C_NODE_MENU_物体选择(bpy.types.Operator):
	bl_idname = 'node.global_node_select_object'
	bl_label = 'Add 物体选择'
	bl_options = {'REGISTER', 'UNDO'}

	def execute(operator, context):
		operator.use_transform = True
		bpy.ops.node.add_node(type='C_SceneNode_物体选择', use_transform=True)
		return {'FINISHED'}
		


classes = (
	C_SceneNode_物体选择,
	C_NODE_MENU_物体选择,
)

def register():
	for c in classes:
		bpy.utils.register_class(c)
		

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)


